package com.efast.dmom.mgmt.service.master.impl;
import java.util.Date;
import java.util.List;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.cafe.portal.entity.base.PortalBaseLov;
import com.efast.cafe.portal.remote.base.PortalBaseLovService;
import com.efast.dmom.mgmt.dao.master.TmBasPartDao;
import com.efast.dmom.mgmt.entity.master.TmBasPart;
import com.efast.dmom.mgmt.service.master.TmBasPartService;
import com.efast.dmom.mgmt.utils.Assist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TmBasPartServiceImpl implements TmBasPartService{
    @Autowired
    private TmBasPartDao tmBasPartDao;
    @Autowired
    private PortalBaseLovService portalBaseLovService;
    
    @Override
    public long getTmBasPartRowCount(Assist assist){
        return tmBasPartDao.getTmBasPartRowCount(assist);
    }
    @Override
    public List<TmBasPart> selectTmBasPart(Assist assist){
        return tmBasPartDao.selectTmBasPart(assist);
    }
    @Override
    public TmBasPart selectTmBasPartByObj(TmBasPart obj){
        return tmBasPartDao.selectTmBasPartByObj(obj);
    }
    @Override
    public TmBasPart selectTmBasPartById(Integer id){
        return tmBasPartDao.selectTmBasPartById(id);
    }
    @Override
    public int insertTmBasPart(TmBasPart value){
        return tmBasPartDao.insertTmBasPart(value);
    }
    @Override
    public int insertNonEmptyTmBasPart(TmBasPart value){
        return tmBasPartDao.insertNonEmptyTmBasPart(value);
    }
    @Override
    public int insertTmBasPartByBatch(List<TmBasPart> value){
        return tmBasPartDao.insertTmBasPartByBatch(value);
    }
    @Override
    public int deleteTmBasPartById(Integer id){
        return tmBasPartDao.deleteTmBasPartById(id);
    }
    @Override
    public int deleteTmBasPart(Assist assist){
        return tmBasPartDao.deleteTmBasPart(assist);
    }
    @Override
    public int updateTmBasPartById(TmBasPart enti){
        return tmBasPartDao.updateTmBasPartById(enti);
    }
    @Override
    public int updateTmBasPart(TmBasPart value, Assist assist){
        return tmBasPartDao.updateTmBasPart(value,assist);
    }
    @Override
    public int updateNonEmptyTmBasPartById(TmBasPart enti){
        return tmBasPartDao.updateNonEmptyTmBasPartById(enti);
    }
    @Override
    public int updateNonEmptyTmBasPart(TmBasPart value, Assist assist){
        return tmBasPartDao.updateNonEmptyTmBasPart(value,assist);
    }

    public TmBasPartDao getTmBasPartDao() {
        return this.tmBasPartDao;
    }

    public void setTmBasPartDao(TmBasPartDao tmBasPartDao) {
        this.tmBasPartDao = tmBasPartDao;
    }
	@Override
	public void save(TmBasPart tmBasPart) {
		String version = "";		
		//获取版本参数的label值
		List<PortalBaseLov> lovList = portalBaseLovService.getPortalBaseLovListTrees("PART_VERSION");
		for(PortalBaseLov lov:lovList) {
			if(lov.getOption_key().equals(tmBasPart.getVersion())) {
				version = lov.getOption_desc();
			}
		}
		if (version == "") {
			tmBasPart.setPartNoVersion(tmBasPart.getPartNo()+"-"+tmBasPart.getVersion());
		} else if (version != "") {
			tmBasPart.setPartNoVersion(tmBasPart.getPartNo()+"-"+version);
		}
		tmBasPart.setCreateTime(new Date());
		tmBasPart.setCreateUser(SpringWebUtils.getRequestUser());
		tmBasPart.setCompanyCode(SpringWebUtils.getRequestCompany());
		tmBasPartDao.insertTmBasPart(tmBasPart);
	}

}